package com.atguigu.nio.zerocopy;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class OldIOServer {

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(7001);
        while (true) {
            Socket socket = serverSocket.accept();
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
            byte[] bytes = new byte[4096];
            long read = 0;
            long total = 0;
            while ((read = dataInputStream.read(bytes, 0, bytes.length) )!= -1) {
                total += read;
            }
            dataInputStream.close();
            System.out.println("接收到的总字节数：" + total);

        }
    }
}
